# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=dtkcore
pkgver=5.6.19
pkgrel=1
epoch=1
pkgdesc='DTK core modules'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/dtkcore"
license=('LGPL3')
depends=('deepin-desktop-base' 'dtkcommon' 'gcc-libs' 'glibc' 'gsettings-qt' 'icu' 'libsystemd'
         'lshw' 'qt5-base' 'uchardet' 'spdlog')
makedepends=('cmake' 'ninja' 'qt5-tools' 'gtest' 'doxygen')
source=("https://github.com/linuxdeepin/dtkcore/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('526db9f0ac8d9f1e1910b1c2cdb5d040bb7c1ad9209b66ff7d520224752619b2b72c63957abc05f1b019ed7cfc18ad65ad9106f0c89812dcd434d43078e8033f')

prepare() {
  cd dtkcore-$pkgver
  sed -i 's|/etc/os-version|/etc/uos-version|' src/dsysinfo.cpp
}

build() {
  cd dtkcore-$pkgver
  cmake . -GNinja \
      -DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules/ \
      -DFEATURES_INSTALL_DIR=lib/qt/mkspecs/features/ \
      -DBUILD_DOCS=ON \
      -DBUILD_TESTING=ON \
      -DBUILD_WITH_SYSTEMD=ON \
      -DQCH_INSTALL_DESTINATION=share/doc/qt \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DCMAKE_INSTALL_LIBEXECDIR=lib \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DDTK_VERSION=$pkgver

  ninja
}

check() {
  cd dtkcore-$pkgver
  # TODO
  ninja test || echo "Tests failed"
}

package() {
  cd dtkcore-$pkgver
  DESTDIR="$pkgdir" ninja install
}
